package com.liao.ten.user;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.fragment.app.Fragment;

import com.liao.ten.R;


public class UserFragment extends Fragment implements View.OnClickListener {
    private ImageView img_user_headImage;
    private TextView tv_user_login;
    private ImageView img_user_favoriteIcon;
    private RelativeLayout layout_user_favorite;
    private ImageView img_user_fontIcon;
    private RelativeLayout layout_user_font;
    private ImageView img_user_aboutIcon;
    private RelativeLayout layout_user_about;
    private ImageView img_user_feedbackIcon;
    private RelativeLayout layout_user_feedback;
    private Context context;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_user_layout, null);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView(view);
    }

    private void initView(View view) {
        context = getContext();
        img_user_headImage = (ImageView) view.findViewById(R.id.img_user_headImage);
        tv_user_login = (TextView) view.findViewById(R.id.tv_user_login);
        img_user_favoriteIcon = (ImageView) view.findViewById(R.id.img_user_favoriteIcon);
        layout_user_favorite = (RelativeLayout) view.findViewById(R.id.layout_user_favorite);
        img_user_fontIcon = (ImageView) view.findViewById(R.id.img_user_fontIcon);
        layout_user_font = (RelativeLayout) view.findViewById(R.id.layout_user_font);
        img_user_aboutIcon = (ImageView) view.findViewById(R.id.img_user_aboutIcon);
        layout_user_about = (RelativeLayout) view.findViewById(R.id.layout_user_about);
        img_user_feedbackIcon = (ImageView) view.findViewById(R.id.img_user_feedbackIcon);
        layout_user_feedback = (RelativeLayout) view.findViewById(R.id.layout_user_feedback);

        img_user_headImage.setOnClickListener(this);
        tv_user_login.setOnClickListener(this);
        layout_user_favorite.setOnClickListener(this);
        layout_user_font.setOnClickListener(this);
        layout_user_about.setOnClickListener(this);
        layout_user_feedback.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.img_user_headImage:
            case R.id.tv_user_login:
                Toast.makeText(context, "登录", Toast.LENGTH_SHORT).show();
                break;
            case R.id.layout_user_favorite:
                Toast.makeText(context, "收藏", Toast.LENGTH_SHORT).show();
                break;
            case R.id.layout_user_font:
                Toast.makeText(context, "字体", Toast.LENGTH_SHORT).show();
                break;
            case R.id.layout_user_about:
                Toast.makeText(context, "关于", Toast.LENGTH_SHORT).show();
                break;
            case R.id.layout_user_feedback:
                Toast.makeText(context, "反馈", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
